home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / Developer Essentials Jul 90 / Technical Docs / Apple II Technical Notes / Technical Notes (Text) / IIGS / TN.IIGS.056 < prev    next >
Encoding:
Text File  |  1989-08-20  |  2.6 KB  |  49 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Apple IIGS
  8. #56:    Managing Dynamic Segments
  9.  
  10. Written by:    Eric Soldan                                          July 1989
  11.  
  12. This Technical Note discusses application difficulties when transferring 
  13. control to dynamic segments during low-memory conditions.
  14. _____________________________________________________________________________
  15.  
  16. Dynamic segments have a drawback in low-memory situations.  If the Loader 
  17. cannot load the dynamic segment because there is not enough memory, it cannot 
  18. just return to the application with an out-of-memory error since your program 
  19. may have pushed parameters onto the stack which the dynamic segment would have 
  20. removed.  If this is the case, the Loader does not have a valid return 
  21. address, so it cannot return to the application; therefore, it gives a fatal 
  22. error and dies.  Because of this problem, an application must make sure that 
  23. there is sufficient memory available before calling the dynamic segment.
  24.  
  25. Just checking the amount of free memory does not guarantee that the dynamic 
  26. segment will load.  If memory is fragmented, the Loader may not be able to 
  27. allocate a block large enough to load the segment, even if the total amount of 
  28. free memory is greater than the size of the segment.  Just checking MaxBlock 
  29. is not a good solution either, since it can indicate that there is not enough 
  30. free memory to load the segment when it is actually available.  However, 
  31. calling MaxBlock is preferable to just checking the amount of free memory, 
  32. since not attempting to load the dynamic segment will not cause a fatal error.
  33.  
  34. Using the method of checking for out-of-memory conditions outlined in Apple 
  35. IIGS Technical Note #51, Reserving Memory for the Toolbox, guarantees that 
  36. there is sufficient space for the dynamic segment.  This method involves 
  37. maintaining a purgeable handle to a segment of memory at least as large as the 
  38. dynamic segment and relocation dictionary.  Before loading the dynamic 
  39. segment, check to see if the handle has been purged.  If it has not been 
  40. purged, then you can load the dynamic segment without worrying about a fatal 
  41. error from the Loader due to an out-of-memory condition.  If it has been 
  42. purged and you cannot reallocate it, then you know that there is not enough 
  43. free memory available to load the dynamic segment.
  44.  
  45.  
  46. Further Reference
  47. _____________________________________________________________________________
  48.     o    GS/OS Reference, Volume 2
  49.     o    Apple IIGS Technical Note #51, Reserving Memory for the Toolbox